﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- OMANE ToggleButtonTemplate -->
    <ControlTemplate x:Key="OMANE_toggleButtonemplate" TargetType="{x:Type ToggleButton}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="20" />
            </Grid.ColumnDefinitions>
            <Border x:Name="Border"
                    Grid.ColumnSpan="2"
                    CornerRadius="2"
                    BorderThickness="1"
                    BorderBrush="{StaticResource BrushCouleur2Base}">
            </Border>
            <Path x:Name="Arrow"
                  Grid.Column="1"
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center"
                  Data="M 0 0 L 4 4 L 8 0 Z">
                <Path.Fill>
                    <SolidColorBrush Color="Black"></SolidColorBrush>
                </Path.Fill>
            </Path>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="UIElement.IsMouseOver" Value="True">
                <Setter Property="Panel.Background" TargetName="Border"   Value="{StaticResource DegradeDefautMouseOver}"></Setter>
            </Trigger>
            <Trigger Property="ToggleButton.IsChecked" Value="True">
                <Setter Property="Panel.Background" TargetName="Border" Value="{StaticResource DegradeDefaultSelected}"></Setter>
                <!--<Setter Property="Shape.Fill" TargetName="Arrow" Value="#66FFFFFF"></Setter>-->
                <Setter Property="Shape.Fill" TargetName="Arrow" Value="Black"></Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    <!-- OMANE ComboBoxTextBoxTemplate -->
    <ControlTemplate TargetType="TextBox" x:Key="ComboBoxTextBoxTemplate">
        <Border Name="PART_ContentHost"
                Background="{TemplateBinding Panel.Background}"
                Focusable="False" />
    </ControlTemplate>
    
    <!-- OMANE ComboBoxItemStyle -->
    <Style TargetType="{x:Type ComboBoxItem}">
        <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
        <Setter Property="FrameworkElement.FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="TextElement.Foreground"  Value="Black"/>
        <Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True"/>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <Border Name="Border" 
                            SnapsToDevicePixels="True" 
                            Padding="2,2,2,2">
                        <ContentPresenter ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
                                          Content="{TemplateBinding ContentControl.Content}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ComboBoxItem.IsHighlighted" Value="True">
                            <!--<Setter Property="Panel.Background" TargetName="Border" Value="Red"/>-->
                        </Trigger>
                        <Trigger Property="UIElement.IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" Value="Black"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- OMANE ComboBoxStyle-->
    <Style TargetType="{x:Type ComboBox}" x:Key="OMANE_cbx">
        <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
        <Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="TextElement.Foreground" Value="Black"/>
        <Setter Property="FrameworkElement.FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid>
                        <ToggleButton ClickMode="Press" 
                                      Name="ToggleButton" 
                                      IsChecked="{Binding Path=IsDropDownOpen, 
                                                          RelativeSource={RelativeSource TemplatedParent}, 
                                                          Mode=TwoWay}"
                                      Focusable="False"
                                      Grid.Column="2"
                                      Template="{StaticResource OMANE_toggleButtonemplate}"/>
                        <ContentPresenter Margin="3,3,23,3" 
                                          HorizontalAlignment="Left" 
                                          Name="ContentSite"
                                          VerticalAlignment="Center"
                                          ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}"
                                          Content="{TemplateBinding ComboBox.SelectionBoxItem}"
                                          IsHitTestVisible="False" />
                        <TextBox Margin="3,3,23,3" 
                                 Visibility="Hidden" 
                                 HorizontalAlignment="Left" 
                                 Name="PART_EditableTextBox" 
                                 Background="ForestGreen"
                                 VerticalAlignment="Center"
                                 Style="{x:Null}"
                                 IsReadOnly="{TemplateBinding IsReadOnly}"
                                 Focusable="True"
                                 xml:space="preserve"
                                 Template="{StaticResource ComboBoxTextBoxTemplate}"/>
                        <Popup Placement="Bottom" 
                               Name="Popup" 
                               Focusable="False" 
                               AllowsTransparency="True"
                               IsOpen="{TemplateBinding ComboBox.IsDropDownOpen}"
                               PopupAnimation="None">
                            <Grid MinWidth="{TemplateBinding FrameworkElement.ActualWidth}"
                                  MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}"
                                  Name="DropDown"
                                  SnapsToDevicePixels="True">
                                <Border BorderBrush="{StaticResource BrushCouleur2Base}"
                                        BorderThickness="1,1,1,1"
                                        Name="DropDownBorder"
                                        Background="White"/>
                                <ScrollViewer Margin="4,6,4,6"
                                              SnapsToDevicePixels="True">
                                    <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ItemsControl.HasItems" Value="False">
                            <Setter Property="FrameworkElement.MinHeight" TargetName="DropDownBorder" Value="95"/>
                        </Trigger>
                        <Trigger Property="UIElement.IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" Value="{StaticResource DegradeDefaultSelected}"/>
                        </Trigger>
                        <Trigger Property="ItemsControl.IsGrouping" Value="True">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
                        </Trigger>
                        <Trigger Property="Window.AllowsTransparency" SourceName="Popup" Value="True">
                            <Setter Property="Border.CornerRadius" TargetName="DropDownBorder" Value="4"/>
                            <Setter Property="FrameworkElement.Margin" TargetName="DropDownBorder" Value="0,2,0,0"/>
                        </Trigger>
                        <Trigger Property="ComboBox.IsEditable" Value="True">
                            <Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
                            <Setter Property="UIElement.Visibility" TargetName="PART_EditableTextBox" Value="Visible"/>
                            <Setter Property="UIElement.Visibility" TargetName="ContentSite" Value="Hidden"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>